package com.filesys.core.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class FileSys {
	
	public static File[] getRootFiles(){
		return getFiles(null);
	}
	
	public static File[] getFiles(File file){
		if(file != null){
			if(file.isDirectory()){
				return file.listFiles();
			}
		}else {
			return File.listRoots();
		}
		return null;
	}
	
	public static FileInputStream getInputStream(File file){
		try {
			return new FileInputStream(file);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public static void main(String[] args) throws IOException {
		File[] files = FileSys.getRootFiles();
		for (File file : files) {
			file.getName();
			file.getAbsoluteFile();
			file.getAbsolutePath();
			file.getCanonicalFile();
			file.getCanonicalPath();
			file.getFreeSpace();
			file.getPath();
			file.getTotalSpace();
			file.getUsableSpace();
			System.out.println("==================================");
			System.out.println("file.getName : " + file.getName());
			System.out.println("file.getPath : " + file.getPath());
			System.out.println("file.getAbsoluteFile : " + file.getAbsoluteFile());
			System.out.println("file.getAbsolutePath : " + file.getAbsolutePath());
			System.out.println("file.getCanonicalFile : " + file.getCanonicalFile());
			System.out.println("file.getCanonicalPath : " + file.getCanonicalPath());
			System.out.println("file.getTotalSpace : " + file.getTotalSpace());
			System.out.println("file.getUsableSpace : " + file.getUsableSpace());
			System.out.println("==================================");
		}
	}
}
